home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1994 December / PSL Monthly Shareware CD-ROM (Public Software Library)(December 1994).bin / prgmming / dos / asm / lambda < prev    next >
Text File  |  1993-02-07  |  4KB  |  144 lines

  1.  
  2. LAMBDA demonstrates the use of Interrupt 10H, Function 11H, Subfunction 0--
  3. 'Character Generator--Load User Text Font.' This service is available only
  4. on EGA and VGA, and on PS/1 & PS/2 emulating VGA.
  5.  
  6. In other words, this is a technique for drawing a character--or a set of
  7. characters--and substituting it for the default character(s).
  8. In this case, we've chosen to draw the Greek character Lambda and put it in
  9. the position normally occupied by 'Cedilla C', or CHR$(128): Ç .
  10. So that, after running LAMBDA.COM, pressing Alt+<Numeric Keypad>128 will
  11. put the Lambda character on the screen. To remove the user-defined
  12. character(s) and return to the default, you can either reverse the code
  13. process, or reset the mode. The latter can be done either by calling
  14. Interrupt 10H, Function 0FH 'Get Mode', immediately followed by
  15. Interrupt 10H, Function 0H 'Set Mode', or with the DOS MODE command, as
  16. for example:
  17.  
  18. C:>MODE CO80
  19.  
  20. What follows is, first a DEBUG script file for creating LAMBDA.COM. Then a
  21. line by line explanation of the code, and then the method for 'drawing' a
  22. character.
  23.  
  24. To create LAMBDA.SCR, create a text file by that name, then paste the
  25. following into it:
  26.  
  27. A 100
  28. MOV AX,1100
  29. MOV BH,E
  30. XOR BL,BL
  31. MOV CX,1
  32. MOV DX,80
  33. MOV BP,114
  34. INT 10
  35. INT 20
  36. DB 0
  37. DB 0
  38. DB 0
  39. DB 18
  40. DB 30
  41. DB 30
  42. DB 30
  43. DB 70
  44. DB 6C
  45. DB C6
  46. DB C3
  47. DB 0
  48. DB 0
  49. DB 0
  50.  
  51. N NEWLAMBDA.COM
  52. RCX
  53. 23
  54. W
  55. Q
  56.  
  57. up to the line immediately above. Be sure to include the blank line (actually
  58. a Carriage Return) immediately above the 'N LAMBDA.COM' line.
  59. Now, provided that DEBUG.COM is in the directory or on the path, type the
  60. following DOS command:
  61.  
  62.     DEBUG<LAMBDA.SCR
  63.  
  64. This will create LAMBDA.COM, which you can run from the command line, or
  65. in DEBUG itself, or any debugger. When run, the program will not display
  66. anything, and will execute in the blink of an eye. The only way you can check
  67. whether it works is by typing Alt+128 and getting a Lambda. You can type
  68. that either at the DOS prompt, or within most text editors.
  69.  
  70.             EXPLANATION
  71.  
  72. This explanation applies only to those lines in LAMBDA.SCR that are the
  73. actual Assembly Language code, and not to the DEBUG command lines, like 'A
  74. 100'.
  75.  
  76. MOV AX,1100    / Character Generator function & Load User Text Font
  77.           Subfunction
  78. MOV BH,E    / Size of character in pixel lines (14 Decimal)
  79. XOR BL,BL    / Block number -- here: 0
  80. MOV CX,1    / Number of characters to be loaded -- here 1, but you can
  81.           do a whole alphabet if you wish
  82. MOV DX,80    / Position in the default character table of character to
  83.           be replaced -- CHR$(128) or 80 Hexadecimal
  84. MOV BP,114    / ES:BP point to the buffer that holds the character(s)
  85.           definition (In a COM file, ES and all other segment
  86.           registers are initialized to the same all-purpose segment,
  87.           so we need not change it)
  88. INT 10        / Call BIOS service
  89. INT 20        / Exit program
  90. DB 0        / Character definition table, consisting of 14 lines, begins
  91.           here. If we were doing multiple characters, they would
  92.           would be contiguous, with each one being exactly 14 bytes
  93.           long.
  94. DB 0
  95. DB 0
  96. DB 18
  97. DB 30
  98. DB 30
  99. DB 30
  100. DB 70
  101. DB 6C
  102. DB C6
  103. DB C3
  104. DB 0
  105. DB 0
  106. DB 0
  107.  
  108.             DRAWING THE CHARACTER
  109.  
  110. The character definition table for Lambda, above, is created by drawing
  111. an analog of the character on a binary grid. That's not as intimidating as
  112. it sounds. Look at the grid below. You'll see a Lambda shape in it, as well
  113. as a direct correspondence between the numeric value of each line and the
  114. numbers in the character table:
  115.  
  116.     00000000
  117.     00000000
  118.     00000000
  119.     00011000    = 18H or 24D
  120.     00110000    = 30H or 48D
  121.     00110000    = ditto
  122.     01110000    = 70H or 112D
  123.     01101100    = 6CH or 108
  124.     11000110    = C6H or 198
  125.     11000011    = C3H or 195
  126.     00000000
  127.     00000000
  128.     00000000
  129.  
  130. Clearly, a reference that translates binary numbers to hex is very helpful
  131. in doing this.
  132. Note that three lines are left blank at the bottom for the cursor.
  133.  
  134. This technique is useful not only for setting up alternate alphabets, but
  135. also for achieving graphical effect in text mode. This is done by creating
  136. character cells that are lines or blocks, and then fitting them together
  137. like a mosaic. For an example, and more on this technique, see _PC Intern_,
  138. by Michael Tischer, Abacus, Chapter 4.8.2.
  139.  
  140. This file prepared by
  141.  
  142. Albert Duro
  143. CIS # 73757,2167
  144.